<?php

namespace app\common\model;

use think\Model;

class Work extends Model
{
    public function client()
    {
        return $this->hasOne('Client', 'id', 'client_id', 'cl', 'LEFT')
            // 设置关联查询方式为join
            ->setEagerlyType(0)
            ->bind([
                'client_name' => 'name'
            ]);
    }

    public function reception()
    {
        return $this->hasOne('User', 'id', 'reception_id', 'rec', 'LEFT')
            ->setEagerlyType(0)
            ->bind([
                'reception_name' => 'name',
                'branch_id' => 'branch_id'
            ]);
    }

    public function repairman()
    {
        return $this->hasOne('User', 'id', 'repairman_id', 'rep', 'LEFT')
            ->setEagerlyType(0)
            ->bind([
                'repairman_name' => 'name'
            ]);
    }

    public function car()
    {
        return $this->hasOne('Car', 'car_num', 'car_num', 'ca', 'LEFT')
            ->setEagerlyType(0)
            ->bind([
                'car_vip' => 'vip',
                'car_moneyleft' => 'moneyleft',
                'car_moneyconsumption' => 'moneyconsumption'
            ]);
    }
}